package com.timesheet.server.dao;

import com.timesheet.server.common.models.TaskTrackerDto;
import com.timesheet.server.core.mapper.Mapper3;
import com.timesheet.server.core.models.TaskTracker;
import com.timesheet.server.core.models.TaskTrackerPk;
import com.timesheet.server.core.util.PMManager;

public class TaskTrackerDao {

	public boolean createTaskTracker(TaskTrackerDto taskTrackerDto) {
		if (taskTrackerDto == null) {
			return false;
		}
		try {

			TaskTracker taskTracker = Mapper3.map(new TaskTracker(), taskTrackerDto);
			TaskTrackerPk taskTrackerPk = new TaskTrackerPk();
			taskTrackerPk.setTaskNo(taskTrackerDto.getTaskNo());
			taskTrackerPk.setTaskStatus(taskTrackerDto.getTaskStatus());
			taskTrackerPk.setTaskType(taskTrackerDto.getTaskType());
			taskTracker.setTaskTrackerPk(taskTrackerPk);
			PMManager.persist(taskTracker);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			return false;
		}

	}
}
